import utils.mysqlUtil;

import java.net.ConnectException;
import java.sql.*;

public class ez {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //调用工具
        Connection conn = mysqlUtil.getConn();
        //编写SQL
        String sql = "select * from dept";
        PreparedStatement preparedStatement = conn.prepareStatement(sql);
        ResultSet resultSet = preparedStatement.executeQuery();
        //遍历
        while(resultSet.next()){
            int id = resultSet.getInt("deptno");
            String dName = resultSet.getString("dname");
            String loc = resultSet.getString("loc");
            //打印
            System.out.println(id+"\t"+dName+"\t"+loc);
        }
    }
}
